package point;

/**题目：反转字符串，要求不修改原来的字符串
 * y: a b c d e   e d c b a
 * @Author Gavin
 * @date 2022.01.10 22:13
 */
public class solution_2 {
    public String solution(String s){
        if(s==null)return null;
        char[] c=s.toCharArray();
        for(int i=0,j=c.length-1;i<j;++i,--j){
            char tmp=c[i];
            c[i]=c[j];
            c[j]=tmp;
        }
        return new String(c);
    }

    public static void main(String[] args) {
        String s="abc";
        char[] chars = s.toCharArray();
        System.out.println(chars);
    }
}
